/* -*- C++ -*- */
#ifndef __coll_Sphere_Header_File__
#define __coll_Sphere_Header_File__

#include "common.h"
#include "core/vmath.h"

namespace core
{


  namespace coll
  {


    template <class T>
    class Sphere
    {
    public:
      Vector3<T> orig;
      T radius;

      Sphere()
      {
	radius = static_cast<T>(0);
      }

      bool isIn(const Sphere<T>& other) const
      {
	Vector3<T> dist = orig - other.orig;
	T len = dist.length();
	return len <= radius + other.radius;
      };

      void addSphere(const Sphere<T>& s)
      {
	Vector3<T> dist = orig - s.orig;
	T len = dist.length();

	if (radius < len + s.radius){
	  radius = len + s.radius;
	}
      }

      void addPoint(const Vector3<T>& p)
      {
	Vector3<T> dist = orig - p;
	T len = dist.length();
	if (len > radius){
	  radius = len;
	}
      }
    };


  }


}


#endif //__coll_Sphere_Header_File__

